CSS Font-Size Keyword Converter - User Guide

Version: 0.7.0

For Sigil E-book Editor


Table of Contents

  1. What This Plugin Does
  2. Installation
  3. Quick Start
  4. Configuration
  5. Understanding the Workflow
  6. Tips and Best Practices
  7. Troubleshooting
  8. Frequently Asked Questions

What This Plugin Does

This plugin converts CSS font-size keywords like small, large, medium, etc. into em or rem units throughout your e-book. It works in three places:

  1. CSS files (external stylesheets like style.css)
  2. Style blocks in HTML headers (<style>...</style>)
  3. Inline styles on HTML elements (<p style="font-size: small;">)

Why Convert?

Some e-readers don't handle CSS keywords consistently. Converting to em/rem units gives you more control over text sizing across different devices and ensures more predictable rendering.

What Gets Converted

The plugin converts these CSS keywords:

What Doesn't Get Converted

The plugin leaves these alone:


Installation

  1. Download the plugin ZIP file: NewUnit_v0.7.0.zip
  2. Open Sigil
  3. Go to Plugins → Manage Plugins
  4. Click Add Plugin
  5. Select the downloaded ZIP file
  6. Click OK
  7. Restart Sigil for the plugin to appear in the menu

Location after install:


Quick Start

Basic Conversion (5 Steps)

  1. Open your e-book in Sigil
  2. Go to Plugins → Edit → CSS Font-Size Keyword Converter
  3. The plugin scans and shows files containing keywords
  4. Check the boxes for files you want to convert
  5. Click Apply Changes

That's it! Your keywords are now converted.

Recommended Workflow

  1. Save your book in Sigil first (File → Save)
  2. Run the plugin as above
  3. Click Preview before applying (optional but recommended)
  4. Review the changes in the preview window
  5. Click Apply Changes if everything looks good
  6. Test your book in an e-reader
  7. Click Undo if you need to revert

Configuration

Click the ⚙ Configuration button to customize conversion settings.

Configuration Window Layout

The window has two columns:

Left Column:

Right Column:

Keyword Values

Each keyword can have a custom numeric value and unit:

Keyword Default Value Converts To
xx-small 0.6 0.6em
x-small 0.75 0.75em
small 0.89 0.89em
medium 1 1em
large 1.2 1.2em
x-large 1.5 1.5em
xx-large 2 2em
smaller 0.85 0.85em
larger 1.15 1.15em

To change a value:

  1. Type a new number in the Value field
  2. Select em or rem radio button
  3. Click Save

Quick Actions:

em vs rem - Which Should I Use?

em (relative to parent):

rem (relative to root):

Not sure? Use rem - it's more predictable.

Font Shorthand (Advanced)

By default, the plugin only converts the font-size: property:

font-size: small;  →  font-size: 0.89em;

You can optionally enable conversion of the font: shorthand property:

font: small Arial;  →  font: 0.89em Arial;
font: bold small/1.5 Georgia;  →  font: bold 0.89em/1.5 Georgia;

To enable:

  1. Check "Also convert font: shorthand property"
  2. Click Save

Important Notes:

When to enable:

When to keep disabled:

Backup Options

The plugin always keeps a memory backup for the Undo button. You can also create external backup files on your hard drive.

To enable external backups:

  1. Check "Create backup copies before converting"
  2. Click Browse and select a folder
  3. Click Save

Backup file naming:

Original: style.css
Backup:   style_20250115_103045.css
          +- Timestamp: YYYYMMDD_HHMMSS

When to use external backups:

When you don't need them:

Saving and Loading Configurations

Save as Default:

Save to Named Config:

Load Named Config:

Example use case:

  1. Create "Kindle Preset" with larger text (all values +0.2)
  2. Create "Kobo Preset" with standard values
  3. Create "Print PDF" with rem units and specific sizing
  4. Load the appropriate preset for each project

Understanding the Workflow

Step-by-Step Explanation

1. File Scanning

When you open the plugin:

  1. It scans all CSS and HTML files in your book
  2. Looks for font-size keywords in:
  3. Counts how many matches each file has
  4. Shows the list with checkboxes

The list shows:

☐ style.css (CSS) - 15 match(es)
☐ chapter1.html (TEXT) - 3 match(es)
☐ chapter2.html (TEXT) - 5 match(es)

2. File Selection

Select files to convert:

Filter options:

Tip: If you've already converted some files, filter to see only the ones that still need conversion.

3. Preview (Optional but Recommended)

Click Preview to see exactly what will change:

Preview window shows:

style.css (5 changes)
--------------------------------

Line 42:
  font-size: small;           [pink background]
  font-size: 0.89em;          [green background]

Line 58:
  [SHORTHAND] font: small Arial;  [blue background, red label]
  font: 0.89em Arial;             [green background]

Color coding:

Preview features:

Tip: Always preview large books before applying.

4. Safety Checks (If Shorthand Enabled)

If you've enabled shorthand conversion, you may see up to two dialogs:

Dialog 1: Unsafe CSS Detected (if any unsafe patterns exist)

Shows patterns like:

font: calc(1em + 2px) small Arial;
font: var(--size) small serif;

These are too complex to convert safely and will be skipped (not converted).

Your options:

What happens to unsafe items:

Dialog 2: Review Safe Shorthand Changes (if any safe shorthand exists)

Shows shorthand patterns that can be safely converted:

font: small Arial;
font: bold large serif;

Summary shows:

Safe font-size conversions: 15 (will be applied)
Safe shorthand conversions: 3 (review below)

These shorthand conversions have been validated as safe.
Unsafe patterns have already been filtered out.

Your options:

Tip: Review the list carefully before choosing "Apply All".

5. Conversion

The plugin processes your selected files:

You'll see:

Converted: style.css (15 change(s))
Converted: chapter1.html (3 change(s))

Successfully converted 18 match(es) in 2 file(s).

During conversion:

After conversion:

6. Undo (If Needed)

If you don't like the results:

  1. Click Undo (orange button)
  2. All modified files are restored to their original state
  3. The file list is re-enabled
  4. You can adjust settings and try again

Undo details:

Important: Undo restores the in-memory backup. If you've saved the book in Sigil after applying changes, you'll need to use Sigil's checkpoints to revert.


Tips and Best Practices

Before Converting

1. Save Your Work

2. Test on a Copy First

3. Review Your CSS

During Conversion

1. Start with Preview

2. Convert in Batches

3. Read the Safety Warnings

Choosing Values

Standard e-book sizes:

Larger overall text:

More contrast between sizes:

Custom per-keyword:

After Conversion

1. Validate Your Book

2. Test in E-readers

3. Check Edge Cases

4. Keep Your Configuration

Working with Mixed Content

Already partially converted:

Multiple CSS files:


Troubleshooting

Common Issues and Solutions

"No font-size keywords found in any files"

Cause: Your book doesn't use CSS keywords, or they're already converted.

Check:

Solution:

"Please select at least one file"

Cause: No checkboxes are checked when you click Preview or Apply.

Solution:

Backup Folder Errors

Error: "No backup folder specified"

Error: "Folder does not exist"

Error: "Folder is not writable"

Error: "Path is not a directory"

Preview or Apply Takes a Long Time

Cause: Large books with many files take time to process.

Solutions:

Changes Don't Look Right

Problem: Converted sizes are too large or too small.

Solution:

  1. Click Undo immediately
  2. Open Configuration
  3. Adjust the numeric values
  4. Click Preview to verify
  5. Apply again

Problem: Some keywords weren't converted.

Check:

Solution:

Undo Doesn't Work

Problem: Undo button is grayed out.

Cause: No changes have been applied yet, or you already undid.

Problem: Undo button doesn't appear.

Cause: The plugin closed before you could undo.

Solution: Use Sigil's checkpoints or reload a backup EPUB.

Plugin Crashes or Freezes

Symptoms:

Solutions:

  1. Wait 2-3 minutes (may be processing)
  2. Check Sigil's debug log for errors
  3. If truly frozen, force quit and restart Sigil
  4. Report the issue with details (see Getting Help below)

Prevention:

Error Messages in Console

The plugin outputs messages to Sigil's debug log. To view:

Common messages:

"Error scanning [file]: [error]"

"Error backing up [file]: [error]"

"Error processing [file]: [error]"

Getting Help

If you continue to have problems:

Gather information:

  1. Plugin version (currently 0.7.0)
  2. Sigil version (Help → About Sigil)
  3. Operating system and version
  4. Specific error message or behavior
  5. Steps to reproduce the problem

Check the debug log:

Report the issue:


Frequently Asked Questions

General Questions

Q: Will this work with all e-readers?

A: em and rem units are part of the CSS standard and widely supported. They work on:

Better compatibility than CSS keywords, which vary by reader.

Q: Can I convert back from em/rem to keywords?

A: No, this plugin only converts keywords → units, not the reverse. If you want to revert, use the Undo button immediately, or restore from a Sigil checkpoint or backup EPUB.

Q: Does this modify my original EPUB file?

A: The plugin modifies the working copy in Sigil. Your original EPUB file on disk is unchanged until you save in Sigil (File → Save).

Q: Will this work with EPUB2 and EPUB3?

A: Yes, it works with both formats. The plugin operates on CSS, which is the same in EPUB2 and EPUB3.

Q: Can I use this on Kindle (AZW3/KFX) files?

A: No, this plugin is for Sigil, which edits EPUB files. For Kindle files, you need to:

  1. Convert to EPUB using Calibre
  2. Edit in Sigil with this plugin
  3. Convert back to Kindle format

Technical Questions

Q: What happens to CSS comments?

A: Comments are completely preserved. The plugin:

  1. Temporarily removes comments before processing
  2. Stores them with unique placeholders
  3. Restores them exactly after conversion

Q: Does this change my HTML structure?

A: No. Only CSS property values change. Your HTML tags, classes, IDs, and structure remain identical.

Q: What if I have both font-size and font shorthand?

A: The plugin handles both:

Q: How does the plugin know what's "unsafe" for shorthand?

A: It looks for:

These patterns can't be reliably converted with simple regex matching.

Q: Can I edit values while in the Preview window?

A: No, the preview is read-only. Close the preview, open Configuration, change values, then preview again.

Q: Does the plugin work on locked or DRM-protected EPUBs?

A: No. Sigil cannot edit DRM-protected files. Remove DRM first using appropriate tools.

Configuration Questions

Q: What's the difference between "Save as Default" and "Save to Named Config"?

A:

You can have one default + multiple named configs.

Q: Where are named configurations stored?

A: In ~/.sigil/NewUnit/configs/ (Mac/Linux) or %APPDATA%/sigil/NewUnit/configs/ (Windows) as JSON files.

Q: Can I share configurations with other people?

A: Yes! Named config files are plain JSON. You can:

  1. Find them in the configs folder
  2. Copy to another computer
  3. Place in the same folder location
  4. They'll appear in "Load Named Config"

Q: Why does the plugin remember my last file selection?

A: It doesn't - file selection resets each time you open the plugin. Only the configuration (values, units, options) is saved.

Conversion Questions

Q: How do I know if conversion was successful?

A: Check:

  1. Status message: "Successfully converted X match(es) in Y file(s)"
  2. Console output shows each file converted
  3. Open a converted file in Sigil's Code View to verify
  4. Test in an e-reader to see the results

Q: Some keywords weren't converted. Why?

A: Common reasons:

Q: Can I convert only specific keywords?

A: No, the plugin converts all 9 keywords based on the configuration. You cannot selectively enable/disable individual keywords.

Workaround: Convert all, then manually revert the ones you don't want.

Q: What if I have custom keywords or browser-specific values?

A: The plugin only handles standard CSS keywords (xx-small through larger). Custom or browser-specific keywords are not converted.

Q: Does conversion affect font families?

A: No, only the size values change. Font families (Arial, Georgia, etc.) remain unchanged.

Workflow Questions

Q: Can I run the plugin multiple times on the same book?

A: Yes, but:

Q: Should I run this before or after other plugins?

A: Order usually doesn't matter. However:

Q: Can I convert part of a book, test it, then convert the rest?

A: Yes! Common workflow:

  1. Select first 5 chapters, convert
  2. Export and test in e-reader
  3. If good, convert remaining chapters
  4. If not, undo and adjust settings

Q: Does this work with Sigil's "Find & Replace"?

A: They're independent. This plugin is specialized for keyword conversion. For other CSS changes, use Find & Replace.

Q: What if I accidentally close the plugin after applying?

A: Undo is lost. Options:

  1. Use Sigil's checkpoints to revert
  2. Close without saving and reopen your EPUB
  3. Restore from your backup copy
  4. Re-run the plugin with inverse values (not recommended)

Troubleshooting Questions

Q: The plugin says "No files found" but I see keywords in my CSS.

A: Check:

Open Sigil's debug log to see what the plugin scanned.

Q: External backup creates files but they're empty.

A: This indicates a write permissions issue. Try:

  1. Choose a different backup folder (like Desktop)
  2. Check folder permissions
  3. Make sure you have enough disk space

Q: How do I know which version of the plugin I have?

A: Check:

  1. Window title: "CSS Font-Size Keyword Converter - Select Files v0.7.0"
  2. Console output: "CSS Font-Size Keyword Converter Plugin v0.7.0"
  3. Plugin Manager in Sigil shows version

Keyboard Shortcuts

The plugin uses standard Sigil/OS keyboard shortcuts:

File Selection:

Preview/Configuration Windows:

Note: No custom keyboard shortcuts are defined by the plugin.


Best Practices Summary

Do:

Don't:


Quick Reference

Default Keyword Values

Keyword Value Unit
xx-small 0.6 em
x-small 0.75 em
small 0.89 em
medium 1 em
large 1.2 em
x-large 1.5 em
xx-large 2 em
smaller 0.85 em
larger 1.15 em

Button Functions

Button Function
Configuration Open settings dialog
Select All Check all visible files
Clear Selection Uncheck all files
Preview Show changes without applying
Apply Changes Convert selected files
Undo Restore original content
Quit Close plugin and save settings

Color Codes in Preview

Color Meaning
Pink background Original CSS (font-size)
Blue background Original CSS (shorthand)
Green background Converted CSS (both types)
Red text [SHORTHAND] label

Version History

Version 0.7.0 (Current)


Contact and Support

Plugin Version: 0.7.0
Last Updated: January 2025

For issues, questions, or suggestions:

  1. Check this documentation first
  2. Review Sigil's debug log
  3. Report issues with version info and error messages

Remember: Always keep backups of your work!


End of User Guide